package org.jeecg.modules.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.jeecg.common.api.ding.DingApi;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.entity.DiyProjectProfessor;
import org.jeecg.modules.entity.DiyTableStatus;
import org.jeecg.modules.entity.ProjectProfessorInfo;
import org.jeecg.modules.service.IProjectProfessorInfoService;
import org.jeecg.modules.service.impl.DiyProjectProfessorServiceImpl;
import org.jeecg.modules.service.impl.ProjectOwnProfessorServiceImpl;
import org.jeecg.modules.vo.Project;
import org.jeecg.modules.vo.ProjectOwnProfessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;

/**
 * @author : ShiJianlong
 * @date : 2020/7/9 15:10
 */
@Api(tags="项目拥有的专家状态")
@RestController
@RequestMapping("/org/projectOwnProfessor")
@Slf4j
public class ProjectOwnProfessorController {

    @Autowired
    private ProjectOwnProfessorServiceImpl projectOwnProfessorService;
    @Autowired
    private DiyProjectProfessorServiceImpl diyProjectProfessorService;
    @Autowired
    private IProjectProfessorInfoService projectProfessorInfoService;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private DingApi dingApi;

    /**
     * 项目拥有的专家状态
     * @param pageNo
     * @param pageSize
     * @return
     */
    @AutoLog(value = "项目拥有的专家状态-分页列表查询")
    @ApiOperation(value="项目拥有的专家状态-分页列表查询", notes="项目拥有的专家状态-分页列表查询")
    @GetMapping(value = "/list/{projectId}")
    public Result<?> queryPageList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   @PathVariable("projectId") String projectId
                                   ) {
        log.info("{projectId==============>}",projectId);
        if(projectId==null){
            Result<Page<ProjectOwnProfessor>> result = new Result<>();
            Page<ProjectOwnProfessor> page = new Page<>(pageNo, pageSize);
            page = projectOwnProfessorService.queryPage(page);//通知公告消息
            result.setSuccess(true);
            result.setResult(page);
            log.info("{page==============>}",page.getRecords());
            return result;
        }else{
            Result<Page<ProjectOwnProfessor>> result = new Result<>();
            Page<ProjectOwnProfessor> page = new Page<>(pageNo, pageSize);
            page = projectOwnProfessorService.queryByProjectId(page,projectId);//通知公告消息
            result.setSuccess(true);
            result.setResult(page);
            log.info("{page==============>}",page.getRecords());
            return result;
        }
    }


}
